#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const double zero = 1e-6;
struct node
{
    int lft,rgt;
}b[N];
int t,n,m,L,V,d[N],v[N],a[N],p[N],ans1,ans2,cnt,lst;
inline double v1(int v0,int a,int s)
{
    int tmp = v0 * v0 + 2 * a * s;
    if (tmp <= 0) return 0;
    return sqrt(tmp);
}
inline double dlts(int v0,int v1,int a) {return (v1 * v1 - v0 * v0) / double(2) / a;}
bool cmp(node a,node b)
{
    return a.rgt < b.rgt;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin >> t;
    while (t--)
    {
        cin >> n >> m >> L >> V;
        ans2 = m;
        for (int i = 1;i <= n;i++) cin >> d[i] >> v[i] >> a[i];
        for (int i = 1;i <= m;i++) cin >> p[i];
        for (int i = 1;i <= n;i++)
        {
            if (a[i] == 0)
            {
                if (d[i] <= p[m] && v[i] > V)
                {
                    ans1++;
                    b[++cnt].lft = lower_bound(p + 1,p + 1 + m,d[i]) - p;
                    b[cnt].rgt = m;
                }
            }
            else if (a[i] > 0)
            {
                if (d[i] <= p[m] && v1(v[i],a[i],p[m] - d[i]) > V)
                {
                    ans1++;
                    int s = ceil(d[i] + dlts(v[i],V,a[i]));
                    b[++cnt].lft = lower_bound(p + 1,p + 1 + m,s) - p;
                    b[cnt].rgt = m;
                }
            }
            else
            {
                if (d[i] <= p[m])
                {
                    int p1 = lower_bound(p + 1,p + 1 + m,d[i]) - p;
                    if (v1(v[i],a[i],p[p1] - d[i]) > V)
                    {
                        ans1++;
                        b[++cnt].lft = p1;
                        int s = d[i] + dlts(v[i],V,a[i]) - zero;
                        b[cnt].rgt = upper_bound(p + 1,p + 1 + m,s) - p - 1;
                    }
                }
            }
        }
        sort(b + 1,b + 1 + cnt,cmp);
        for (int i = 1;i <= cnt;i++)
        {
            if (b[i].lft > lst)
            {
                ans2--;
                lst = b[i].rgt;
            }
        }
        cout << ans1 << ' ' << ans2 << endl;
        ans1 = ans2 = cnt = lst = 0;
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
